/*
 * ReadBoundaryConditionforThermalResponse.h
 *Read boudary condition data to compute ablation
 *  Created on: Jan 11, 2020
 *      Author: liuxiao
 */


#pragma once

#include "Material.h"
#include "libmesh/meshfree_interpolation.h"
using std::string;
using std::vector;

class Function;

class ReadBoundaryConditionforThermalResponse : public Material
{
public:
	ReadBoundaryConditionforThermalResponse(const InputParameters & parameters);

protected:
  virtual void computeProperties();

private:
  void readFile();
  void interpolate(std::vector<Real> &qc, std::vector<Real>  &hr,std::vector<Real>  &tw, std::vector<Real>  &pe,std::vector<Point> &pts, Real t);
  void check();
//  cold wall heat flux at given wall temperature
  MaterialProperty<Real> & _qc;
  //  cold wall heat flux at 0K
    MaterialProperty<Real> & _qc_0K;
//  recovery enthalpy
  MaterialProperty<Real> & _hr;
//  pressure at boundary edge,Pa;
  MaterialProperty<Real> & _Pe;
//  pressure at boundary edge,atm;
  MaterialProperty<Real> & _Pe_atm;
  //  pressure of O2 at boundary edge,atm;
  MaterialProperty<Real> & _Pe_O2;
  //  pressure of N2 at boundary edge,atm;
  MaterialProperty<Real> & _Pe_N2;
  //  average molar mass of gas out of boundary layer,kg/mol
  MaterialProperty<Real> & _M_e;
//wall temperature at which heat flux computed
  MaterialProperty<Real> & _Tw_qc;
//wall temperature
   const VariableValue & _Tw;
   //partial pressure of O2 at boundary edge,1
   Real _Pe_O2_p;
   //partial pressure of N2 at boundary edge,1
   Real _Pe_N2_p;
   //  get average molar mass of gas out of boundary layer,kg/mol
   Real _M_e_p;

  string _data_file;
  string _flux_file;
  vector<vector<Real> > _src_qc;
  vector<vector<Real> > _src_hr;
  vector<vector<Real> > _src_tw0;
  vector<vector<Real> > _src_pe;
  vector<vector<Point> >_src_pts;
  vector<Real> _time_step;
  vector<string> _field_name;

  vector<InverseDistanceInterpolation<LIBMESH_DIM> *  > _idis;
  int _num_pts;
  int _num_time_step;
  std::vector<Real> _scale;
  Real _fluxcoff;
};

template<>
InputParameters validParams<ReadBoundaryConditionforThermalResponse>();

